<html>
<head><meta charset="utf-8"><title>resolver and platforms behavior · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html">resolver and platforms behavior</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="235770918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235770918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235770918">(Apr 23 2021 at 00:47)</a>:</h4>
<p>Is there some documentation on what exactly to expect in the <code>resolve</code> section is expected to include? I'm specifically wondering if that map contains cross platform dependencies or if they've been "resolved" out.</p>
<p>For more context, I'm working on <a href="https://github.com/google/cargo-raze">https://github.com/google/cargo-raze</a> which uses cargo metadata to generate Bazel dependencies and we need to resolve dependencies for a specified set of platform triples. Is the <code>resolve</code> section something I could use or would that only contain information about a single platform?</p>



<a name="235771382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235771382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235771382">(Apr 23 2021 at 00:54)</a>:</h4>
<p><a href="https://doc.rust-lang.org/cargo/commands/cargo-metadata.html">https://doc.rust-lang.org/cargo/commands/cargo-metadata.html</a> should have some answers. In particular, "resolve" includes all platforms unless the <code>--filter-platform</code> flag is used.</p>



<a name="235783966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235783966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235783966">(Apr 23 2021 at 04:10)</a>:</h4>
<blockquote>
<p>By default, this includes all dependencies for all target platforms.</p>
</blockquote>
<p>How are target platforms determined?</p>



<a name="235860973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235860973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235860973">(Apr 23 2021 at 15:27)</a>:</h4>
<p>Not sure if I understand the question correctly. When you say <code>--filter-platform=x86_64-apple-darwin</code>, cargo runs <code>rustc --print=cfg --target x86_64-apple-darwin</code>, parses the output, and then has its own <code>cfg</code> comparison code. Target names are matched as exact strings. If you don't include <code>--filter-platform</code>, it includes all <code>[target]</code> dependency tables (includes all named targets and assumes all <code>cfg</code> expressions are true).</p>



<a name="235864628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235864628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235864628">(Apr 23 2021 at 15:51)</a>:</h4>
<p>And what if <code>[target]</code> is unspecified?<br>
<a href="https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies">https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies</a></p>



<a name="235864918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235864918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235864918">(Apr 23 2021 at 15:53)</a>:</h4>
<p>Sorry, I'm not sure what that means.  If there are no <code>[target]</code> tables, then the package does not have any target-specific dependencies.</p>



<a name="235865391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235865391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235865391">(Apr 23 2021 at 15:56)</a>:</h4>
<p>right, so what is the default behavior in that case when generating the <code>resolve</code> metadata? Does any target filtering happen by default or are all targets included? In other words, is setting nothing the same as setting everything?</p>



<a name="235865818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235865818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235865818">(Apr 23 2021 at 15:59)</a>:</h4>
<p>Oh, yeah.  If you don't include <code>--filter-platform</code>, there is no filtering (everything is included).</p>



<a name="235865989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235865989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235865989">(Apr 23 2021 at 16:00)</a>:</h4>
<p>Everything from <code>[target]</code>?</p>



<a name="235866072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235866072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235866072">(Apr 23 2021 at 16:01)</a>:</h4>
<p>Yea, every <code>[target]</code> (and all the non-target tables of course).</p>



<a name="235866119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235866119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235866119">(Apr 23 2021 at 16:01)</a>:</h4>
<p>To clarify a bit, I understand the behavior of <code>--filter-platform</code> now. But now I'm wondering about the <code>[target]</code> field when empty</p>



<a name="235866324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235866324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235866324">(Apr 23 2021 at 16:02)</a>:</h4>
<p>The specific situation is if there's no targets specified, and I go and run <code>cargo metadata</code> on a linux machine, would it generate the same <code>resolve</code> section as a windows machine using the same manifest at the same time?</p>



<a name="235866473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235866473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235866473">(Apr 23 2021 at 16:03)</a>:</h4>
<p>yep.  It is essentially giving you what appears in <code>Cargo.lock</code> which is platform-agnostic.</p>



<a name="235866548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/resolver%20and%20platforms%20behavior/near/235866548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> UebelAndre <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/resolver.20and.20platforms.20behavior.html#235866548">(Apr 23 2021 at 16:03)</a>:</h4>
<p>Awesome! Thanks for walking me through that! Much appreciated :D</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>